<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>strftime</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_009_102">&nbsp;</a>NAME</h4><blockquote>
strftime - convert date and time to a string
</blockquote><h4><a name = "tag_000_009_103">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="time.h.html">time.h</a>&gt;

size_t strftime(char *<i>s</i>, size_t <i>maxsize</i>, const char *<i>format</i>,
    const struct tm *<i>timptr</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_009_104">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>strftime()</i>
function places bytes into the array pointed to by
<i>s</i>
as controlled by the string pointed to by
<i>format</i>.
The
<i>format</i>
string consists of zero or more conversion specifications and
ordinary characters.
A conversion specification consists of a % character and a terminating
conversion character that determines the conversion specification's
behaviour.
All ordinary characters (including the terminating
null byte) are copied unchanged into the array.
If copying takes place between objects that overlap, the
behaviour is undefined.
No more than
<i>maxsize</i>
bytes are placed into the array.
Each conversion specification
is replaced by appropriate characters
as described in the following list.
The appropriate characters are determined by the program's locale
and by the values contained in the structure pointed to by
<i>timptr</i>.
<p>
Local timezone information is used as though
<i>strftime()</i>
called
<i><a href="tzset.html">tzset()</a></i>.
<dl compact>

<dt>%a<dd>is replaced by the locale's abbreviated weekday name.

<dt>%A<dd>is replaced by the locale's full weekday name.

<dt>%b<dd>is replaced by the locale's abbreviated month name.

<dt>%B<dd>is replaced by the locale's full month name.

<dt>%c<dd>is replaced by the locale's appropriate date and time representation.

<dt>%C<dd>is replaced by the century number (the year divided by 100 and truncated
to an integer) as a decimal number [00-99].

<dt>%d<dd>is replaced by the day of the month as a decimal number [01,31].

<dt>%D<dd>same as %m/%d/%y.

<dt>%e<dd>is replaced by the day of the month as a decimal number [1,31];
a single digit is preceded by a space.

<dt>%h<dd>same as %b.

<dt>%H<dd>is replaced by the hour (24-hour clock) as a decimal number [00,23].

<dt>%I<dd>is replaced by the hour (12-hour clock) as a decimal number [01,12].

<dt>%j<dd>is replaced by the day of the year as a decimal number [001,366].

<dt>%m<dd>is replaced by the month as a decimal number [01,12].

<dt>%M<dd>is replaced by the minute as a decimal number [00,59].

<dt>%n<dd>is replaced by a newline character.

<dt>%p<dd>is replaced by the locale's equivalent of either a.m. or p.m.

<dt>%r<dd>is replaced by the time in a.m. and
p.m. notation; in the POSIX locale this is
equivalent to %I:%M:%S %p.

<dt>%R<dd>is replaced by the time in 24 hour notation (%H:%M).

<dt>%S<dd>is replaced by the second as a decimal number [00,61].


<dt>%t<dd>is replaced by a tab character.

<dt>%T<dd>is replaced by the time (%H:%M:%S).

<dt>%u<dd>is replaced by the weekday as a decimal number [1,7], with 1 representing
Monday.

<dt>%U<dd>is replaced by the week number of the year (Sunday as the first day of
the week) as a decimal number [00,53].


<dt>%V<dd>is replaced by the week number of the year (Monday as the first day of the
week) as a decimal number [01,53].  If the week containing 1 January has
four or more days in the new year, then it is considered week 1.  Otherwise,
it is the last week of the previous year, and the next week is week 1.

<dt>%w<dd>is replaced by the weekday as a decimal number [0,6], with 0 representing
Sunday.

<dt>%W<dd>is replaced by the week number of the year (Monday as the first day of
the week) as a decimal number [00,53].  All days in a new year preceding
the first Monday are considered to be in week 0.

<dt>%x<dd>is replaced by the locale's appropriate date representation.

<dt>%X<dd>is replaced by the locale's appropriate time representation.

<dt>%y<dd>is replaced by the year without century as a decimal number [00,99].

<dt>%Y<dd>is replaced by the year with century as a decimal number.

<dt>%Z<dd>is replaced by the timezone name or abbreviation, or by no bytes
if no timezone
information exists.

<dt>%%<dd>is replaced by %.

</dl>
<p>
If a conversion specification does not correspond to any
of the above, the behaviour is undefined.
<h5><a name = "tag_000_009_104_001">&nbsp;</a>Modified Conversion Specifiers</h5>
Some conversion specifiers can be modified by the E or O modifier characters
to indicate that an alternative format or specification should be used rather
than the one normally used by the unmodified conversion specifier.  If the
alternative format or specification does not exist for the current locale,
(see ERA in the <b>XBD</b> specification, <b>Section 5.3.5</b>)
the behaviour will be as if the unmodified conversion specification were
used.
<dl compact>

<dt>%Ec<dd>is replaced by the locale's alternative appropriate date and
time representation.

<dt>%EC<dd>is replaced by the name of the base year (period) in the
locale's alternative representation.

<dt>%Ex<dd>is replaced by the locale's alternative date representation.

<dt>%EX<dd>is replaced by the locale' alternative time representation.

<dt>%Ey<dd>is replaced by the offset from %EC (year only) in the locale's
alternative representation.

<dt>%EY<dd>is replaced by the full alternative year representation.

<dt>%Od<dd>is replaced by the day of the month, using the locale's
alternative numeric symbols, filled as needed with leading zeros if there is
any alternative symbol for zero, otherwise with leading spaces.

<dt>%Oe<dd>is replaced by the day of month, using the locale's
alternative numeric symbols, filled as needed with leading spaces.

<dt>%OH<dd>is replaced by the hour (24-hour clock) using the locale's
alternative numeric symbols.

<dt>%OI<dd>is replaced by the hour (12-hour clock) using the locale's
alternative numeric symbols.

<dt>%Om<dd>is replaced by the month using the locale's alternative numeric
symbols.

<dt>%OM<dd>is replaced by the minutes using the locale's alternative numeric
symbols.

<dt>%OS<dd>is replaced by the seconds using the locale's alternative numeric
symbols.

<dt>%Ou<dd>is replaced by the weekday as a number in the locale's alternative
representation (Monday=1).

<dt>%OU<dd>is replaced by the week number of the year (Sunday as the first
day of the week, rules corresponding to %U)
using the locale's alternative numeric symbols.

<dt>%OV<dd>is replaced by the week number of the year (Monday as the first
day of the week, rules corresponding to %V)
using the locale's alternative numeric symbols.

<dt>%Ow<dd>is replaced by the number of the weekday (Sunday=0) using
the locale's alternative numeric symbols.

<dt>%OW<dd>is replaced by the week number of the year (Monday as the first
day of the week) using the locale's alternative numeric symbols.

<dt>%Oy<dd>is replaced by the year (offset from %C) using the locale's
alternative numeric symbols.

</dl>
</blockquote><h4><a name = "tag_000_009_105">&nbsp;</a>RETURN VALUE</h4><blockquote>
If the total number of resulting bytes including the terminating
null byte is not more than
<i>maxsize</i>,
<i>strftime()</i>
returns the number of bytes placed into the array pointed to by
<i>s</i>,
not including the terminating null byte.  Otherwise, 0 is returned and the
contents of the array are indeterminate.
</blockquote><h4><a name = "tag_000_009_106">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4><a name = "tag_000_009_107">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_009_108">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
The range of values for %S is [00,61] rather than [00,59] to allow
for the occasional leap second and even more infrequent double leap second.
<p>
Some of the conversion specifications
marked EX are duplicates of others.
They are included for compatibility with
<i>nl_cxtime()</i>
and
<i>nl_ascxtime()</i>,
which were published in Issue 2.
<p>
Applications should use %Y (4-digit years) in preference to %y
(2-digit years).
</blockquote><h4><a name = "tag_000_009_109">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_009_110">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="asctime.html">asctime()</a></i>,
<i><a href="clock.html">clock()</a></i>,
<i><a href="ctime.html">ctime()</a></i>,
<i><a href="difftime.html">difftime()</a></i>,
<i><a href="gmtime.html">gmtime()</a></i>,
<i><a href="localtime.html">localtime()</a></i>,
<i><a href="mktime.html">mktime()</a></i>,
<i><a href="strptime.html">strptime()</a></i>,
<i><a href="time.html">time()</a></i>,
<i><a href="utime.html">utime()</a></i>,
<i><a href="time.h.html">&lt;time.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
